package com.itheima.steawmdemo;

import java.util.ArrayList;

public class StreamDemo6 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            list.add(i);
        }

        /*ArrayList<Integer> list2 = new ArrayList<>();
        list.forEach(i -> {
            if (i % 2 == 0) {
                list2.add(i);
            }
        });
        System.out.println(list2);*/

        list.stream().filter(i -> i%2 == 0).forEach(i -> System.out.println(i));
        System.out.println("----------------------");
        for (Integer i : list) {
            System.out.println(i);
        }
    }
}
